package cn.wolfcode.service;

import cn.wolfcode.domain.OperateIntergralVo;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

@LocalTCC
public interface IUsableIntegralService {

    /**
     * 积分减少业务逻辑
     * @param operateIntergralVo
     */
    void decrIntergral(OperateIntergralVo operateIntergralVo);

    /**
     * 减少积分
     */
    @TwoPhaseBusinessAction(name = "decrIntergralTry",
            commitMethod = "decrIntergralCommit",
            rollbackMethod = "decrIntergralRollback")
    void decrIntergralTry(@BusinessActionContextParameter(paramName = "operateIntergralVo") OperateIntergralVo operateIntergralVo, // 把vo放到上下文当中
                          BusinessActionContext context);
    void decrIntergralCommit(BusinessActionContext context);
    void decrIntergralRollback(BusinessActionContext context);

    /**
     * 退款后积分增加
     * @param operateIntergralVo
     */
    void incrIntergral(OperateIntergralVo operateIntergralVo);

    /**
     * 增加积分
     */
    @TwoPhaseBusinessAction(name = "incrIntergralTry",
            commitMethod = "incrIntergralCommit",
            rollbackMethod = "incrIntergralRollback")
    void incrIntergralTry(@BusinessActionContextParameter(paramName = "operateIntergralVo") OperateIntergralVo operateIntergralVo, // 把vo放到上下文当中
                          BusinessActionContext context);
    void incrIntergralCommit(BusinessActionContext context);
    void incrIntergralRollback(BusinessActionContext context);
}
